package com.lzc.util.handle;

/**
 * JSON格式类
 * Created by bin on 2021/6/11.
 */
public enum JsonCodeEnum {
    SUCCESS(1, "成功"),
    FAIL(-1, "失败"),
    OVERTIME(-2, "已超时或过期"),
    EMPTY(0, "空数据"),
    PARAMETER_INVALID(-3, "参数不合法");

    JsonCodeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 代码
     */
    private Integer code;
    /**
     * 消息
     */
    private String message;

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    @Override
    public String toString() {
        return "";
    }

    /**
     * 判断是否是正确返回
     *
     * @param jsonCode 枚举
     * @return 是=true
     */
    public static boolean isSuccess(JsonCodeEnum jsonCode) {
        if (jsonCode != null) {
            if (jsonCode.equals(JsonCodeEnum.SUCCESS)) {
                return true;
            }
        }
        return false;
    }
}
